package com.cj.webapp.user.controller;

import com.cj.webapp.account.controller.ReBackServlet;
import com.cj.webapp.common.utils.HFJsonUtil;
import com.cj.webapp.common.utils.MapDetail;
import com.cj.webapp.user.dto.UserDto;
import com.cj.webapp.user.service.UserServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.mail.Session;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;

/**
 * 个人中心界面
 * Created by dell on 2018/1/23.
 */
//@WebServlet(name = "user_personalInfo")
public class PersonalServlet extends HttpServlet {
    private static final Logger logger = LoggerFactory.getLogger(PersonalServlet.class);
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        HttpSession session=request.getSession();
        //
        String head = request.getParameter("head");
        String body=request.getParameter("body");
        logger.info("网关请求返回报文信息："+head +body);

        UserDto dto=new UserDto();
        dto.setName(MapDetail.resMap.get("phone").toString());
        UserServiceImpl service=new UserServiceImpl();
        UserDto userInfo = service.getUserMessage(dto);
        request.setAttribute("user",userInfo);
        request.getRequestDispatcher("page/index/index.jsp").forward(request,response);
        //response.sendRedirect("page/index/index.jsp");

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         doPost(request,response);
    }
}
